﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace temaIp
{
    class Program
    {
        static List<Client> clients = new List<Client>();
        static int option;
        

        static void meniu()
        {
            
            System.Console.WriteLine("1.Adaugati client");
            System.Console.WriteLine("2.Adaugati masina");
            System.Console.WriteLine("3.Afisati date client");
            System.Console.WriteLine("4.Eliminare masina");
            System.Console.WriteLine("5.Exit");
            System.Console.WriteLine("");
            System.Console.WriteLine("");
            System.Console.WriteLine("Alegerea dumneavoastra: ");

            option = Console.Read();
            switch (option)
            {
                case 49 :
                {
                    Console.Clear();
                    Client client1 = new Client();   
                    System.Console.WriteLine("Nume: ");
                    string line = null;
                    line = Console.ReadLine();
                    client1.setName(Console.ReadLine());
                    System.Console.WriteLine("Varsta: ");
                    option = Convert.ToInt32(Console.ReadLine());
                    client1.setAge(option);
                    clients.Add(client1);
                    Console.Clear();
                    meniu();
                    break;
                }
                case 50 :
                    {
                        Console.Clear();
                        System.Console.WriteLine("Carui client ii atribuim masina?");
                        string nume = null;
                        foreach (Client person in clients)
                        {
                            nume = person.getName();
                            System.Console.WriteLine(nume);
                            System.Console.WriteLine("");
                        }
                        string magicName = null;
                        System.Console.WriteLine("Raspuns: ");
                        string d = Console.ReadLine();
                        magicName = System.Console.ReadLine();

                        Console.Clear();
                        System.Console.WriteLine("Ce tip de masina doriti sa adaugati?");
                        System.Console.WriteLine("1.Mini");
                        System.Console.WriteLine("2.Coupe");
                        System.Console.WriteLine("3.Sedan");
                        System.Console.WriteLine("");
                        System.Console.WriteLine("Raspunsul: ");

                        int number = Console.Read();
                        if ( number == 49)
                        {
                            Console.Clear();
                            AbstractCar car1 = CarMini.Instance();
                            System.Console.WriteLine("Ce culoare doriti sa aibe masina?");
                            string b = Console.ReadLine();
                            car1.setColour(Console.ReadLine());
                            System.Console.WriteLine("Ce dotari sa aibe masina?");
                            car1.setAddons(Console.ReadLine());
                            System.Console.WriteLine("Ce dimensiuni sa aibe masina?");
                            car1.setDim(Console.ReadLine());
                            System.Console.WriteLine("Ce motorizare doriti?"); 
                            car1.setMotto(Console.ReadLine());
                            System.Console.WriteLine("Ce nume are masina?");
                            car1.setName(Console.ReadLine());
                            System.Console.WriteLine("Ce transmisie sa aibe masina?");
                            car1.setTransmission(Console.ReadLine());
                            car1.setType();
                            foreach ( Client persona in clients )
                                if (persona.getName() == magicName)
                                {
                                    persona.add(car1);
                                    goto HERE;
                                    break;
                                }
                        }
                        if ( number == 50 )
                        {
                            Console.Clear();
                            AbstractCar car1 = CarCoupe.Instance();
                            System.Console.WriteLine("Ce culoare doriti sa aibe masina?");
                            string c = Console.ReadLine();
                            car1.setColour(Console.ReadLine());
                            System.Console.WriteLine("Ce dotari sa aibe masina?");
                            car1.setAddons(Console.ReadLine());
                            System.Console.WriteLine("Ce dimensiuni sa aibe masina?");
                            car1.setDim(Console.ReadLine());
                            System.Console.WriteLine("Ce motorizare doriti?");
                            car1.setMotto(Console.ReadLine());
                            System.Console.WriteLine("Ce nume are masina?");
                            car1.setName(Console.ReadLine());
                            System.Console.WriteLine("Ce transmisie sa aibe masina?");
                            car1.setTransmission(Console.ReadLine());
                            car1.setType();
                            foreach (Client persona in clients)
                                if (persona.getName().Equals(magicName))
                                {
                                    persona.add(car1);
                                    goto HERE;
                                    break;
                                }
                        }
                        if ( number == 51 )
                        {
                            Console.Clear();
                            AbstractCar car1 = CarSedan.Instance();
                            System.Console.WriteLine("Ce culoare doriti sa aibe masina?");
                            string a = Console.ReadLine();
                            car1.setColour(Console.ReadLine());
                            System.Console.WriteLine("Ce dotari sa aibe masina?");
                            car1.setAddons(Console.ReadLine());
                            System.Console.WriteLine("Ce dimensiuni sa aibe masina?");
                            car1.setDim(Console.ReadLine());
                            System.Console.WriteLine("Ce motorizare doriti?");
                            car1.setMotto(Console.ReadLine());
                            System.Console.WriteLine("Ce nume are masina?");
                            car1.setName(Console.ReadLine());
                            System.Console.WriteLine("Ce transmisie sa aibe masina?");
                            car1.setTransmission(Console.ReadLine());
                            car1.setType();
                            foreach (Client persona in clients)
                                if (persona.getName().Equals(magicName))
                                {
                                    persona.add(car1);
                                    goto HERE;
                                    break;
                                }
                        }
                        System.Console.WriteLine("");
                        System.Console.WriteLine("Apasati o tasta pentru a continua");
                        System.Console.Read();
                        Console.Clear();
                    HERE:
                        meniu();
                        break;
                    }
                case 51 :
                    {
                        Console.Clear();
                        System.Console.WriteLine("Carui client ii afisam datele?");
                        string nume = null;
                        foreach (Client person in clients)
                        {
                            nume = person.getName();
                            System.Console.WriteLine(nume);
                            System.Console.WriteLine("");
                        }
                        string magicName = null;
                        string e = Console.ReadLine();
                        System.Console.WriteLine("Raspuns: ");
                        magicName = System.Console.ReadLine();
                        System.Console.WriteLine("");
                        foreach (Client persona in clients)
                            if (persona.getName() == magicName)
                            {
                                persona.showDetails();
                                System.Console.WriteLine("");
                                persona.showList();
                                break;
                            }

                        System.Console.WriteLine("");
                        System.Console.WriteLine("Apasati o tasta pentru a continua");
                        System.Console.Read();
                        Console.Clear();
                        meniu();
                        break;
                    }
                case 52 :
                    {
                        Console.Clear();
                        System.Console.WriteLine("Carui client ii eliminam o masina?");
                        string nume = null;
                        foreach (Client person in clients)
                        {
                            nume = person.getName();
                            System.Console.WriteLine(nume);
                            System.Console.WriteLine("");
                        }
                        string magicName = null;
                        string f = Console.ReadLine();
                        System.Console.WriteLine("Raspuns: ");
                        magicName = System.Console.ReadLine();

                        System.Console.WriteLine("");
                        foreach (Client persona in clients)
                            if (persona.getName().Equals(magicName))
                            {
                                persona.show();
                                System.Console.WriteLine("");
                                System.Console.WriteLine("Ce masina doriti sa eliminam?");
                                string masina = null;
                                masina = System.Console.ReadLine();
                                persona.remove(masina);
                                break;
                            }
                        System.Console.WriteLine("");
                        System.Console.WriteLine("Apasati o tasta pentru a continua");
                        System.Console.Read();
                        Console.Clear();

                        meniu();
                        break;
                    }
                case 53 :
                    System.Environment.Exit(-1);
                    break;
                default :
                    Console.Clear();
                    meniu();
                    break;
            }

            

        }
        static void Main(string[] args)
        {
            
            //meniu(); -> nu am avut destul timp sa termin meniul, mai aveam cateva lucruri, merge destul de bine si asa
            //decomentand merge meniul
            //dedesubt sunt testarile functiilor care merg foarte bine fara erori :)
            


            /*Client client1 = new Client();
            client1.setName("vasile");
            client1.setAge(21);
            client1.showDetails();
            AbstractCar car1 = CarCoupe.Instance();
            car1.setColour("rosie");
            car1.setAddons("addon1");
            car1.setDim("mare");
            car1.setMotto("motto1");
            car1.setName("BMW Coupe");
            car1.setTransmission("transmission1");
            car1.setType();
            client1.add(car1);
            client1.show();
            client1.remove(car1);
            Console.Clear();
            client1.showDetails();
            client1.show();*/



        }
    }
}
